<%@ page language="java" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"></meta>
    <base href="/"/>
    <title>提交订单-${site}</title>
    <link rel="stylesheet" type="text/css" href="/css/index.css"/>
    <script type="text/javascript" src="js/jquery-3.7.1.min.js"></script>
    <script type="text/javascript">
        //用于用户中心左边菜单栏的选择项的样式
        function setSelectedClass(url) {
            $('div.cont ul.list li a[href~="' + url + '"]').parent().addClass("current");
        }
    </script>
    <style>
        .friend_pay {
            color: orange;

        }

        .order_completed {
            width: 148px;
            margin: 30px 0;
            background-color: orange;
            color: white;
            font-size: 20px;
            *display: block;
            height: 44px;
            border: none;
            /*text-indent: -9999px;*/
            overflow: hidden;
            cursor: pointer;
            /*line-height: 120px;*/

        }
    </style>
</head>
<body class="second">
<div class="brand_list container_2">
    <div class="header">
        <h1 class="logo">
            <a title="" style="background:url(images/logo.png);" href="/">电子商务平台</a>
        </h1>
        <ul class="shortcut">
            <li class="first"><a href="ucenter">我的账户</a></li>
            <li><a href="/order/user">我的订单</a></li>
            <li class='last'><a href="">使用帮助</a></li>
        </ul>
        <p class="loginfo">
            <c:if test="${not empty sessionScope.user}">
                ${user.account}您好，欢迎您来到${site}购物！[<a href="/logout" class="reg">安全退出</a>]
            </c:if>
            <c:if test="${empty sessionScope.user}">
                [<a href="/login">登录</a>
                <a class="reg" href="/register">免费注册</a>]
            </c:if>
        </p>
    </div>

    <div class="wrapper clearfix">
        <div class="position mt_10">
            <span>您当前的位置：</span> <a href=""> 首页</a> » 成功提交订单
        </div>
        <div class="myshopping m_10">
            <ul class="order_step">
                <li><span class="first">1、查看购物车</span></li>
                <li class="current_prev"><span>2、填写核对订单信息</span></li>
                <li class="last_current"><span>3、成功提交订单</span></li>
            </ul>
        </div>

        <div class="cart_box m_10">
            <div class="title">成功提交订单</div>
            <div class="cont">
                <p class="order_stats">
                    <img width="48px" height="51px" alt=""
                         src="images/front/right.gif"><strong class="f14">订单已提交</strong>
                </p>

                <div class="stats_box">
                    <h3>订单信息</h3>
                    <table width="100%" class="form_table t_l orange">
                        <col width="75px"/>
                        <col/>

                        <tbody>
                        <tr>
                            <th>订单编号：</th>
                            <td class="f18 bold red2">${order.no}</td>
                        </tr>
                        <tr>
                            <th>订单金额：</th>
                            <td class="f18 bold red2">￥<b>${order.totalMoney}</b></td>
                        </tr>
                        <tr>
                            <th>支付方式：</th>
                            <td class="f18 bold red2">${order.payType == 1 ? '在线支付' : '货到付款'}</td>
                        </tr>
                        <tr>
                            <th>订单状态：</th>
                            <td class="f18 bold red2">${order.status == "1" ? '待支付' : (order.status == "2" ? '已支付' : (order.status == "3" ? '已发货' : '已完成'))}</td>
                        </tr>
                        </tbody>
                    </table>

                    <!--不是货到付款并且支付方式为线上支付-->
                    <c:if test="${order.payType == 1 && order.status == 1}">
                        <input type="hidden" name="orderNo" id="orderNo" value="${order.no}">
                        <input type="hidden" name="orderId" id="orderId" value="${order.id}">
                        <input type="hidden" name="payType" value="${order.payType}">
                        <input class="submit_pay" id="submit_pay" type="submit" value="立即支付"/>
                        <input class="friend_pay" type="button" id="friendPay" value="朋友代付"/>
                    </c:if>

                    <!--订单已完成按钮-->
                    <c:if test="${order.status == 4}">
                        <input class="order_completed" type="button" value="订单已完成"/>
                    </c:if>
                </div>
            </div>
        </div>
    </div>
    <div class="footer">
        <p class="links">
            <a href="">关于我们</a>|<a href="">常见问题</a>|<a href="">安全交易</a>|<a href="">购买流程</a>|<a
                href="">如何付款</a>|<a href="">联系我们</a>|<a href="">合作提案</a>
        </p>
        Copyright 蜗牛学苑© 2015-2024 <a class="copyys" target="_blank" href="">蜀ICP备01000010号</a>
    </div>
</div>
</body>
<script>
    $(function () {
        $("#submit_pay").click(function () {
            $.ajax({
                url: "/order/pay/now",
                type: "post",
                data: {
                    orderId: $("#orderId").val(),
                    orderNo: $("#orderNo").val()
                },
                success: function (res) {
                    if (res) {
                        window.location.href = res;//跳转到支付页面

                    } else {
                        alert("支付宝提交失败,请重新尝试");
                    }
                }
            })
        });
    })
</script>
</html>
